//
//  Prefix-Header.swift
//  TinyShopKeeper_Swift
//
//  Created by huangtao on 16/4/29.
//  Copyright © 2016年 fish. All rights reserved.
//

import Foundation
import UIKit

let ScreenHeight = CGRectGetHeight(UIScreen .mainScreen() .bounds)
let ScreenWidth = CGRectGetWidth(UIScreen .mainScreen() .bounds)
let ApplicationTintColor = MZColor(233, green: 73, blue: 65)
//用户单例
let UserInfo = MZUserInfo.userInfo
//持久化
let UserDefaults = NSUserDefaults.standardUserDefaults()
//通知
let NotificationCenter = NSNotificationCenter.defaultCenter()


func MZColor(red: CGFloat, green: CGFloat, blue: CGFloat) -> UIColor
{
    let all: CGFloat = 255
   return UIColor(red: red/all, green: green/all, blue: blue/all, alpha: 1)
}

func pathByName(fileName:String) -> String
{
    return  NSBundle.mainBundle().pathForAuxiliaryExecutable(fileName)!
}

func imageByName(fileName:String) -> UIImage?
{
    return UIImage(contentsOfFile: pathByName(fileName))
}



//6.3
let RedDeepColor = MZColor(250 , green: 29, blue: 55)
let RedMiddleColor = MZColor(251, green: 75, blue: 48)
let RedShallowColor = MZColor(244, green: 123, blue: 112)

let BlueDeepColor = MZColor(20, green: 149, blue: 238)
let BlueMiddleColor = MZColor(26, green: 181, blue: 239)
let BlueShallowColor = MZColor(98, green: 194, blue: 242)

//订单颜色
public enum ColorType:Int{
    case Red  //红色
    case Blue //蓝色
}

public enum ColorStyle:Int
{
    case Shallow //浅色
    case Middle //中间色
    case Deep //深色
}

func colorByType(type:ColorType,style:ColorStyle) -> UIColor{
    //红色
    if type == .Red{
        if style == .Deep{
            return RedDeepColor
        }else if style == .Middle{
            return RedMiddleColor
        }else{
            return RedShallowColor
        }
        
    }
    //蓝色
    if style == .Deep{
        return BlueDeepColor
    }else if style == .Middle{
        return BlueMiddleColor
    }else{
        return BlueShallowColor
    }
    
}


//多个颜色
func chartColorByCount(count:Int) -> [UIColor]
    
{
    
    let currentColor:[UIColor] = [MZColor(241, green: 54, blue: 43), MZColor(110, green: 189, blue: 148), MZColor(253, green: 203, blue: 44), MZColor(22, green: 181, blue: 249), MZColor(16, green: 140, blue: 39), MZColor(45, green: 92, blue: 34)]
    
    var color:[UIColor] = []
    
    for i in 0..<(count){
        
        let index = i % currentColor.count
        
        color .append(currentColor[index])
        
    }
    
    return color
    
}






